<#import "../macro/components.ftl" as components/>
<#include "../macro/layout_default.ftl"/>

<@body>
<script src="/misc/app/js/lgs_cust.js"></script>
</@body>

<@layout_default>
<div class="box">

    <ul class="nav nav-tabs" role="tablist">
        <li role="presentation"><a href="/lgsDepot/list">节点管理</a></li>
        <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">对象管理</a>
        </li>

    </ul>

    <div class="box-header with-border">
    <#--<span class="pull-right text-muted">共 ${custList.resultTotal} 条记录</span>-->
        <form class="form-inline" action="/lgsCust/list">
            <div class="input-group">
                <div class="input-group-addon">对象名称</div>
                <input type="text" class="form-control" style="width: 260px" name="keyword" value="${keyword!}"/>
            </div>
            <div class="input-group">
                <div class="input-group-addon">状态</div>
                <select class="form-control" name="state">
                    <option value="">全部</option>
                    <option value="1" ${(state?exists && state == 1)?string("selected","")}>正常</option>
                    <option value="0" ${(state?exists && state == 0)?string("selected","")}>停用</option>
                </select>
            </div>

            <button type="submit" class="btn btn-warning"><i class="fa fa-search"></i> 查询</button>
            <button type="button" class="btn btn-default" name="btn_new_cust" data-toggle="modal" data-target="#md_new_cust"><i class="fa fa-plus"></i> 新增对象</button>
        </form>
    </div>

    <div class="box-body">
        <table class="table table-striped table-hover">
            <tr>
                <th>ID</th>
                <th>对象名称</th>
                <th>对象编码</th>
                <th>区域</th>
                <th>详细地址</th>
                <th>状态</th>
                <th>录入时间</th>
                <th>录入人</th>
                <th>操作</th>
            </tr>
            <#if (custList.result?size > 0)>
                <#list custList.result as item>
                    <tr>
                        <td>${item.id!}</td>
                        <td>${item.custName!}</td>
                        <td>${item.custCode!}</td>
                        <td>${item.areaName!}</td>
                        <td>${item.addr!}</td>
                        <td><#if item.state==1><span class="text-green">正常</span><#elseif item.state==0><span class="text-yellow">停用</span><#else><span class="text-danger">未知</span></#if></td>
                        <td>${item.createTime?number_to_datetime}</td>
                        <td>${item.creatorName!}</td>
                        <td>
                            <#if item.source==1>
                                <button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#md_edit_cust" data-cust-id="${item.id!}">编辑</button>
                            </#if>

                        </td>
                    </tr>
                </#list>
            <#else>
                <tr>
                    <td class="text-center text-muted" colspan="6"><i class="fa fa-info-circle"></i> 没有记录</td>
                </tr>
            </#if>
        </table>
    </div>
    <!-- /.box-body -->
    <div class="box-footer text-center">
        <@components.pagination "/lgsCust/list?keyword=${keyword!}&state=${state!}&page=$page",custList.page,custList.pageTotal/>
    </div>
</div>

<!-- new -->
<div class="modal" id="md_new_cust" tabindex="-1">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel"><i class="fa fa-plus"></i> 新增对象</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" name="form_new_cust">
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 客户名称:</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="custName" placeholder="仅限汉字、数字、字母"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 客户编码:</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="custCode" placeholder="仅限数字、字母"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 区域:</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="areaId">
                                <option value="">请选择</option>
                                <#list areaList as item>
                                    <option value="${item.id}">${item.areaname}</option>
                                </#list>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 详细地址:</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control"  name="addr"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 状态:</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="state">
                                <option value="1">正常</option>
                                <option value="0">停用</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="btn_save_new_cust">保存</button>
            </div>
        </div>
    </div>
</div>

<!--  edit -->
<div class="modal" id="md_edit_cust" tabindex="-1">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel"><i class="fa fa-plus"></i> 编辑对象</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" name="form_edit_cust">
                    <input type="hidden" name="id"/>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 客户名称:</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="custName" placeholder="仅限汉字、数字、字母"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 客户编码:</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="custCode" placeholder="仅限数字、字母"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 区域:</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="areaId">
                                <option value="">请选择</option>
                                <#list areaList as item>
                                    <option value="${item.id}">${item.areaname}</option>
                                </#list>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 详细地址:</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control"  name="addr"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 状态:</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="state">
                                <option value="1">正常</option>
                                <option value="0">停用</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="btn_save_edit_cust">保存</button>
            </div>
        </div>
    </div>
</div>


</@layout_default>